export interface User {
  id: string;
  email: string;
  name: string;
  organizations: string[];
}

export interface Project {
  id: string;
  name: string;
  description?: string;
  owner: string;
  environments: Environment[];
  modules: ModuleInstance[];
  createdAt: string;
  updatedAt: string;
}

export interface Environment {
  id: string;
  name: string;
  type: 'dev' | 'staging' | 'prod';
  secrets: Record<string, string>;
  modules: ModuleInstance[];
}

export interface Module {
  id: string;
  name: string;
  description?: string;
  version: string;
  author: string;
  tags: string[];
  schema: any;
  actions: ModuleAction[];
  dependencies: string[];
  createdAt: string;
  updatedAt: string;
}

export interface ModuleInstance {
  moduleId: string;
  version: string;
  config: Record<string, any>;
  environment: string;
}

export interface ModuleAction {
  name: string;
  description?: string;
  input: any;
  output: any;
}

export interface Secret {
  key: string;
  value: string;
  environment: string;
}

export interface Config {
  apiUrl: string;
  token?: string;
  currentProject?: string;
  currentEnvironment?: string;
}

export interface VersionInfo {
  version: string;
  tag: string;
  createdAt: string;
  author: string;
  changelog?: string;
}

export class CLIError extends Error {
  code: string;
  statusCode?: number;

  constructor(message: string, code: string = 'CLI_ERROR', statusCode?: number) {
    super(message);
    this.name = 'CLIError';
    this.code = code;
    this.statusCode = statusCode;
    Object.setPrototypeOf(this, CLIError.prototype);
  }
}